﻿using Quartz.Impl;
using Quartz;

namespace MyWeb.TaskGrpc
{
    public class MyScheduler
    {
        public static async Task Start()
        {
            // 创建 SchedulerFactory
            var schedulerFactory = new StdSchedulerFactory();

            // 创建 Scheduler
            var scheduler = await schedulerFactory.GetScheduler();

            // 创建 JobDetail
            var jobDetail = JobBuilder.Create<MyJob>()
                .WithIdentity("MyJob", "MyGroup")
                .Build();

            // 创建 Trigger
            var trigger = MyTrigger.Create();

            // 将 JobDetail 和 Trigger 绑定到 Scheduler
            await scheduler.ScheduleJob(jobDetail, trigger);

            // 启动 Scheduler
            await scheduler.Start();
        }
    }
}
